﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Framework.Zhaogang.Log.Domain.Services
{
    public class LogService
    {
        /// <summary>
        /// 写入用户行为日志
        /// </summary>
        /// <param name="uiLogs"></param>
        public void WriteUILog(Stream uiLogsStream)
        {
            if (bool.Parse(ConfigurationManager.AppSettings["IsEnabled"]))
            {
                var logs = Compression.Decompress<List<UILogDTO>>(uiLogsStream);
                WritterFactory.GetWritter("UILogDTO").Write(logs);
            }
        }

        /// <summary>
        /// 写入用户行为日志，弱类型参数
        /// </summary>
        /// <param name="uiLogsStream"></param>
        public void WriteUILog2(Stream uiLogsStream)
        {
            if (bool.Parse(ConfigurationManager.AppSettings["IsEnabled"]))
            {
                var logs = Compression.Decompress<List<UILogDTO>>(uiLogsStream);
                //内部含uilog的json内容字符串
                WritterFactory.GetWritter("UILogDTO2").Write(logs);
            }
        }

        /// <summary>
        /// 写入应用程序日志
        /// </summary>
        /// <param name="appLogs"></param>
        public void WriteAppLog(Stream appLogsStream)
        {
            if (bool.Parse(ConfigurationManager.AppSettings["IsEnabled"]))
            {
                var logs = Compression.Decompress<List<AppLogDTO>>(appLogsStream);
                WritterFactory.GetWritter("AppLogDTO").Write(logs);
            }
        }
    }
}
